package com.suning.sawp.service.impl.oga;

import java.util.List;
import java.util.Map;

import org.joda.time.LocalDate;
import org.springframework.stereotype.Service;

import com.google.common.collect.Maps;
import com.suning.sawp.dto.oga.bi.SimpleRange;
import com.suning.sawp.po.bi.BIStaffDevelopSale;
import com.suning.sawp.po.bi.BiDevelopSale;
import com.suning.sawp.po.bi.BiStaffArriveSaleDayEntity;
import com.suning.sawp.po.bi.BiStaffDevelopDayEntity;
import com.suning.sawp.po.bi.BiStaffDevelopWithSale;
import com.suning.sawp.service.impl.oga.bi.BIDevelopSaleService;
import com.suning.sawp.service.impl.oga.bi.support.Callback;
import com.suning.sawp.service.impl.oga.bi.support.SimpleRanges;

/**
 * 拓展销售统计
 * 
 * @author 13071602
 *
 */
@Service("biDevelopSaleServiceDay")
public class BIDevelopSaleServiceDay extends BIDevelopSaleService {

    @Override
    protected BiDevelopSale queryStoreRecommendSale(String storeCode, int offset, Callback<String> span) {
        Map<String, Object> paramMap = Maps.newHashMap();
        LocalDate localDate = new LocalDate().plusDays(offset);
        paramMap.put("statsDate", localDate.toString("yyyyMMdd"));
        paramMap.put("storeCode", storeCode);
        span.withValue(localDate.toString("yyyyMMdd"));
        return dalClient.queryForObject("BIDevelopSaleService.queryStoreDevelop_DAY", paramMap,
                BiStaffArriveSaleDayEntity.class);
    }

    @Override
    protected List<? extends BIStaffDevelopSale> queryStaffsArriveSale(String storeCode, String cateCode, int offset) {
        Map<String, Object> paramMap = Maps.newHashMap();
        LocalDate localDate = new LocalDate().plusDays(offset);
        paramMap.put("statsDate", localDate.toString("yyyyMMdd"));
        paramMap.put("storeCode", storeCode);
        paramMap.put("cateCode", cateCode);
        return dalClient.queryForList("BIDevelopSaleService.queryStaffsArriveSale_DAY", paramMap,
                BiStaffArriveSaleDayEntity.class);
    }

    @Override
    protected List<? extends BIStaffDevelopSale> queryStaffsRecommendSale(String storeCode, String cateCode,
            int offset) {
        Map<String, Object> paramMap = Maps.newHashMap();
        LocalDate localDate = new LocalDate().plusDays(offset);
        paramMap.put("statsDate", localDate.toString("yyyyMMdd"));
        paramMap.put("storeCode", storeCode);
        paramMap.put("cateCode", cateCode);
        return dalClient.queryForList("BIDevelopSaleService.queryStaffsRecommendSale_DAY", paramMap,
                BiStaffArriveSaleDayEntity.class);
    }

    @Override
    protected SimpleRange<String> getStaffSaleRange(int offset) {
        LocalDate localDate = new LocalDate().plusDays(offset);
        SimpleRange<String> range = SimpleRanges.day(localDate,"yyyyMMdd");
        return range;
    }

    @Override
    protected List<? extends BiStaffDevelopWithSale> queryStaffDevelopSaleLeaderBoard(String storeCode, int top,
            int timeOffset) {
        Map<String, Object> paramMap = Maps.newHashMap();
        LocalDate localDate = new LocalDate().plusDays(timeOffset);
        paramMap.put("statsDate", localDate.toString("yyyyMMdd"));
        paramMap.put("storeCode", storeCode);
        paramMap.put("top", top);
        return dalClient.queryForList("BIDevelopSaleService.queryDevelopSaleLeaderBoard_DAY", paramMap,
                BiStaffDevelopDayEntity.class);
    }

    @Override
    protected BIStaffDevelopSale queryStaffDevelopingSale(String storeCode, String staffId, int offset,
            Callback<String> span) {
        throw new UnsupportedOperationException();
    }

    @Override
    protected BIStaffDevelopSale queryStaffArriveSale(String storeCode, String staffId, int offset,
            Callback<String> span) {
        throw new UnsupportedOperationException();
    }

    @Override
    protected BIStaffDevelopSale queryStaffRecommendSale(String storeCode, String staffId, int offset,
            Callback<String> span) {
        throw new UnsupportedOperationException();
    }

    @Override
    protected BiDevelopSale queryStoreDevelopingSale(String storeCode, int offset, Callback<String> span) {
        throw new UnsupportedOperationException("外拓不支持天维度查询");
    }

    @Override
    protected BiDevelopSale queryStoreArriveSale(String storeCode, int offset, Callback<String> span) {
        throw new UnsupportedOperationException("到店不支持(门店,天)维度查询");
    }

    @Override
    protected List<? extends BIStaffDevelopSale> queryStaffsDevelopingSale(String storeCode, String cateCode,
            int offset) {
        throw new UnsupportedOperationException("外拓不支持天维度查询");
    }

}
